package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.Service;
import vo.Rmb;

/**
 * Servlet implementation class YueServlet
 */
@WebServlet("/Yue")
public class YueServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private Service service = new Service();

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8"); 
		String methon = request.getParameter("methon");
		if("1".equals(methon)){
			String yhm = request.getParameter("yhm");
			String pwd = request.getParameter("pwd");
			Rmb denglu = service.denglu(yhm, pwd);
			request.setAttribute("denglu", denglu);
			request.getRequestDispatcher("yue.jsp").forward(request, response);			
		}else if("2".equals(methon)){
			String yhm = request.getParameter("yhm");
			String pwd = request.getParameter("pwd");
			Rmb denglu = service.denglu(yhm, pwd);
			request.setAttribute("zhanghu", denglu);
			request.getRequestDispatcher("qukuan.jsp").forward(request, response);
		}else if("3".equals(methon)){
			String yhm = request.getParameter("yhm");
			String pwd = request.getParameter("pwd");
			Rmb denglu = service.denglu(yhm, pwd);
			request.setAttribute("zhanghu", denglu);
			request.getRequestDispatcher("zhuanzhang.jsp").forward(request, response);
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
